package club.hicode.daydayup.threadlocal.demo1;

import cn.hutool.core.util.RandomUtil;
import com.github.jsonzou.jmockdata.JMockData;
import com.github.jsonzou.jmockdata.TypeReference;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;

/**
 * 通用查询
 *
 * @author Liu Chunfu
 * @date 2018-08-09 下午5:46
 **/
@Slf4j
public class CommonQuery extends Thread implements FightQuery {

    private String airName;

    public CommonQuery(String airName) {
        this.airName = airName;
    }

    private List<String> arrayList = new ArrayList<>(10);

    @Override
    public List<String> getList() {
        return arrayList;
    }

    @Override
    public void run() {
        try {
            TimeUnit.SECONDS.sleep(RandomUtil.randomInt(5));
            IntStream.range(0, RandomUtil.randomInt(10)).boxed()
                    .forEach(i -> arrayList.add(airName + "#" + RandomUtil.randomString(4)));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
